package com.umakr.ax.app.web;

import com.umakr.ax.common.service.PluginCouponResultService;
import com.umakr.ax.core.base.AbstractController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * <p>
 * ${table.comment}  前端控制器
 * </p>
 *
 * @author Umakr-Code-Generator
 * @since 2017-12-30
 */
@Controller
@RequestMapping("/api/pluginCouponResult")
public class PluginCouponResultAppController extends AbstractController {

	@Autowired
	PluginCouponResultService resultService;

	/**
	 * 商家针对一个优惠券查看优惠券的使用情况
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/listCouponsByCouponId")
	@ApiOperation(value = "商家优惠券统计列表")
	public Object listCouponsByCouponId(ModelMap modelMap, Long couponId,Integer status) {
		return setSuccessModelMap(modelMap,resultService.listCouponsByCouponId(couponId,status));
	}


	/**
	 * 普通用户查看自己的优惠券列表
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/listCouponsByUserIdAndStatus")
	@ApiOperation(value = "获取用户优惠券列表")
	public Object listCouponsByUserIdAndStatus(ModelMap modelMap, Long userId,Integer status) {
		return setSuccessModelMap(modelMap,resultService.listCouponsByUserIdAndStatus(userId, status));
	}


	/**
	 * 普通用户查看自己的优惠券列表
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/deleteOneCouponById")
	@ApiOperation(value = "获取用户优惠券列表")
	public Object deleteOneCouponById(ModelMap modelMap, Long id) {
		return setSuccessModelMap(modelMap,resultService.deleteOneCouponById(id));
	}

	/**
	 * 卡券验证接口
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/checkCouponByCheckNum")
	@ApiOperation(value = "卡券验证接口")
	public Object checkCouponByCheckNum(ModelMap modelMap, Long checkUserId,String checkNum) {
		return setSuccessModelMap(modelMap,resultService.checkCouponByCheckNum(checkUserId, checkNum));
	}

	/**
	 * 卡券领取接口
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/saveCouponResult")
	@ApiOperation(value = "卡券领取接口")
	public Object saveCouponResult(ModelMap modelMap, Long couponId,Long userId) {
		return setSuccessModelMap(modelMap,resultService.saveCouponResult(couponId, userId));
	}

	/**
	 * 根据优惠券码扫码之后获取优惠券信息
	 * 信息包含是否可用
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/findCouponsInfoByCouponNum")
	@ApiOperation(value = "根据优惠券码获取优惠券信息")
	public Object findCouponsInfoByCouponNum(ModelMap modelMap, String couponNum,Long couponId) {
		return setSuccessModelMap(modelMap,resultService.findCouponsInfoByCouponNum(couponNum,couponId));
	}

	/**
	 * 获取优惠券状态信息
	 * 模板使用
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/getCouponStatusInfo")
	@ApiOperation(value = "获取优惠券状态信息")
	public Object getCouponStatusInfo(ModelMap modelMap, Long couponId,Long userId) {
		return setSuccessModelMap(modelMap,resultService.getCouponStatusInfo(couponId,userId));
	}

	/**
	 * 获取优惠券领取状态
	 * 模板使用
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/getCouponResultForTmp")
	@ApiOperation(value = "获取优惠券领取状态")
	public Object getCouponResultForTmp(ModelMap modelMap, Long couponId,Long userId) {
		return setSuccessModelMap(modelMap,resultService.getCouponResultForTmp(couponId,userId));
	}
}